home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / c / host / RCS / Host_ByNetAddr.c,v < prev    next >
Encoding:
Text File  |  1992-06-05  |  2.9 KB  |  146 lines

  1. head     1.3;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    jhh:1.3; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.3
  10. date     88.12.15.09.25.24;  author ouster;  state Exp;
  11. branches ;
  12. next     1.2;
  13.  
  14. 1.2
  15. date     88.07.18.10.54.36;  author mendel;  state Exp;
  16. branches ;
  17. next     1.1;
  18.  
  19. 1.1
  20. date     88.06.30.11.06.44;  author ouster;  state Exp;
  21. branches ;
  22. next     ;
  23.  
  24.  
  25. desc
  26. @@
  27.  
  28.  
  29. 1.3
  30. log
  31. @Change type of addrPtr from Address to char *.
  32. @
  33. text
  34. @/* 
  35.  * Host_ByNetAddr.c --
  36.  *
  37.  *    Source code for the Host_ByNetAddr library procedure.
  38.  *
  39.  * Copyright 1988 Regents of the University of California
  40.  * Permission to use, copy, modify, and distribute this
  41.  * software and its documentation for any purpose and without
  42.  * fee is hereby granted, provided that the above copyright
  43.  * notice appear in all copies.  The University of California
  44.  * makes no representations about the suitability of this
  45.  * software for any purpose.  It is provided "as is" without
  46.  * express or implied warranty.
  47.  */
  48.  
  49. #ifndef lint
  50. static char rcsid[] = "$Header: Host_ByNetAddr.c,v 1.2 88/07/18 10:54:36 mendel Exp $ SPRITE (Berkeley)";
  51. #endif not lint
  52.  
  53. #include <stdio.h>
  54. #include <host.h>
  55. #include <hostInt.h>
  56.  
  57.  
  58. /*
  59.  *-----------------------------------------------------------------------
  60.  *
  61.  * Host_ByNetAddr --
  62.  *
  63.  *    Return information about the host with the given local network
  64.  *    address.
  65.  *
  66.  * Results:
  67.  *    A Host_Entry structure describing the host.  If no such host
  68.  *    exists, NULL is returned.  The Host_Entry is statically
  69.  *    allocated, and may be modified on the next call to any Host_
  70.  *    procedure.
  71.  *
  72.  * Side Effects:
  73.  *    The host database is opened if it wasn't already.
  74.  *
  75.  *-----------------------------------------------------------------------
  76.  */
  77.  
  78. Host_Entry *
  79. Host_ByNetAddr(addrType, addrPtr)
  80.     Host_NetType      addrType;       /* The type of network the host
  81.                      * is on */
  82.     char *           addrPtr;        /* Pointer to the address in the
  83.                      * format for the network */
  84. {
  85.     register Host_Entry    *entry;
  86.  
  87.     if (Host_Start() == 0) {
  88.     switch (addrType) {
  89.         case HOST_ETHER: {
  90.         int i;
  91.         unsigned char *address = (unsigned char *) addrPtr;
  92.  
  93.         while (1) {
  94.             entry = Host_Next();
  95.             if (entry == (Host_Entry *) NULL) {
  96.             break;
  97.             }
  98.             for (i = HOST_ETHER_ADDRESS_SIZE - 1; i >= 0; i--) {
  99.             if (entry->netAddr.etherAddr[i] != address[i]) {
  100.                 break;
  101.             }
  102.             if (i == 0) {
  103.                 return entry;
  104.             }
  105.             }
  106.         }
  107.         break;
  108.         }
  109.     }
  110.     }
  111.     return (Host_Entry *) NULL;
  112. }
  113. @
  114.  
  115.  
  116. 1.2
  117. log
  118. @Added include for <sprite.h> so module will compile. Fixed incorrect 
  119. cast.
  120. @
  121. text
  122. @d17 1
  123. a17 1
  124. static char rcsid[] = "$Header: Host_ByNetAddr.c,v 1.1 88/06/30 11:06:44 ouster Exp $ SPRITE (Berkeley)";
  125. a20 1
  126. #include <sprite.h>
  127. d49 1
  128. a49 1
  129.     Address           addrPtr;        /* Pointer to the address in the
  130. @
  131.  
  132.  
  133. 1.1
  134. log
  135. @Initial revision
  136. @
  137. text
  138. @d17 1
  139. a17 1
  140. static char rcsid[] = "$Header: proto.c,v 1.2 88/03/11 08:39:08 ouster Exp $ SPRITE (Berkeley)";
  141. d21 1
  142. d59 1
  143. a59 1
  144.         unsigned char *address = (char *) addrPtr;
  145. @
  146.